<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>个人信息</title>
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="__CSS__/user_info.css"/>
		<link rel="stylesheet" type="text/css" href="__CSS__/mui.min.css"/>
		<script src="__JS__/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="__JS__/mui.min.js" type="text/javascript" charset="utf-8"></script>


	</head>
	<script>
		(function(doc, win) {
			var docEl = doc.documentElement,
				resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
				recalc = function() {
					var clientWidth = docEl.clientWidth;
					if(!clientWidth) return;
					docEl.style.fontSize = 100 * (clientWidth / 640) + 'px';
				};
			if(!doc.addEventListener) return;
			win.addEventListener(resizeEvt, recalc, false);
			doc.addEventListener('DOMContentLoaded', recalc, false);
		})(document, window);
	</script>
	<body>
		<div class="container">
			<header>
				<a class="btn btn-danger" href="javascript:history.go(-1);"><i></i></a>

				<span>个人信息</span>
			</header>
			<ul class="main">
				<li>头像 <img id="logo" src="__IMG__/{$Think.session.pic }" alt=""><i></i></li>
				<a href="{:url('set_name')}"><li>昵称<span class="sate">{$Think.session.username }未设置</span><i></i></li></a>
				<li>账号<span class="account">{$Think.session.mobile }</span></li>
			</ul>
			<!--<div class="zhezhao"></div>-->
			<!--<ul class="tip">-->
				<!--<li>拍照</li>-->
			<!--</ul>-->
		</div>	
	</body>
	<script>
        //营业执照
        document.getElementById('logo').addEventListener('tap', function(event) {

            var btnArray = [{
                title: "拍照"
            }, {
                title: "从相册选择"
            }];
            plus.nativeUI.actionSheet({
                title: "选择照片",
                cancel: "取消",
                buttons: btnArray
            }, function(e) {
                var index = e.index;
                switch (index) {
                    case 0:
                        break;
                    case 1:
                        var cmr = plus.camera.getCamera();
                        cmr.captureImage(function(path) {
                            document.getElementById("yyzzs").src= "file://" + plus.io.convertLocalFileSystemURL(path);
                            appendFile(document.getElementById("logo").src);
                        }, function(err) {});
                        break;
                    case 2:
                        plus.gallery.pick(function(path) {
                            document.getElementById("logo").src= path;
                            appendFile(path);
                        }, function(err) {}, null);
                        break;
                }
            });
        }, false);
        // 添加文件
        var f1=null;
        function appendFile(path){
            var img = new Image();
            img.src = path;        // 传过来的图片路径在这里用。
            img.onload = function () {
                var that = this;
                //生成比例
                var w = that.width,
                    h = that.height,
                    scale = w / h;
                w = 200 || w;              //480  你想压缩到多大，改这里
                h = w / scale;
                //生成canvas
                var canvas = document.createElement('canvas');
                var ctx = canvas.getContext('2d');
                canvas.setAttribute("width",w);
                canvas.setAttribute("height",h);
                ctx.drawImage(that, 0, 0, w, h);
                var base64 = canvas.toDataURL('image/jpeg', 1 || 0.8 );   //1最清晰，越低越模糊。有一点不清楚这里明明设置的是jpeg。弹出 base64 开头的一段 data：image/png;却是png。哎开心就好，开心就好
                //e = base64;
                f1 = base64;   // 把base64数据丢过去，上传要用。
                // alert(f1);
                //console.log(base64)
            }
        }
	</script>